package com.blb.common.util;

import com.blb.common.util.MyEurekaClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 监听springboot程序启动
 */
@Component
public class ApplicationStartListener implements ApplicationRunner {

    @Autowired
    private MyEurekaClient myEurekaClient;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        System.out.println("程序启动开始注册");
        String register = myEurekaClient.register();
        if("success".equals(register)){
            System.out.println("注册成功");
            myEurekaClient.renew();
        }else{
            System.out.println("注册失败");
        }
    }
}
